package com.gagakuai.reflect.invoke;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/*
 * @program: common-starters
 * @description: get字段获取
 * @author: houhong
 * @create: 2023-06-29 23:07
 */
public class GetFieldInvoker implements Invoker {

    private final Field field;

    public GetFieldInvoker(Field field) {
        this.field = field;
    }

    @Override
    public Object invoke(Object target, Object[] args) throws IllegalAccessException, InvocationTargetException {
        return field.get(target);
    }

    @Override
    public Class<?> getType() {
        return field.getType();
    }
}